package ua.com.hackaton.core;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import ua.com.hackaton.core.awt.Rectangle2D;

import java.util.Map;
import java.util.TreeMap;

/**
 * Created by IntelliJ IDEA.
 * User: Eugene Borshch
 * Date: 6/25/11
 * Time: 5:52 PM
 * To change this template use File | Settings | File Templates.
 */
public class TagCloudView extends View
{
    /**
     * The view bounds.
     */
    private Rect mRect = new Rect();
    /**
     * The user interface thread handler.
     */
    private Handler mHandler;
    private Map<String, Integer> data_map;
    private Settings settings;


    public TagCloudView(Context context, Map<String, Integer> data_map, Settings settings)
    {
        super(context);
        this.data_map = data_map;
        this.settings = settings;
    }

    protected void onDraw(Canvas canvas)
    {

        super.onDraw(canvas);
        canvas.getClipBounds(mRect);
        int top = mRect.top;
        int left = mRect.left;
        int width = mRect.width();
        int height = mRect.height();

        CloudCreator cloudCreator = new CloudCreator(width, height, getData(),settings);
        cloudCreator.random2();
        cloudCreator.doLayout(canvas, this);
        cloudCreator.drawCloud(canvas);

    }

    private Map<String, Integer> getData()
    {
       if(data_map!=null)
            return  data_map;

         Map<String, Integer> wordsMap = new TreeMap<String, Integer>();
        wordsMap.put("CloudMe", 100);
        wordsMap.put("Calls", 50);
        wordsMap.put("Contacts", 20);
        wordsMap.put("Friends", 40);
        wordsMap.put("Incoming", 35);
        wordsMap.put("Outgoing", 34);
        wordsMap.put("List", 15);
        wordsMap.put("Call", 30);
        wordsMap.put("Android", 40);
        wordsMap.put("Java", 20);
        wordsMap.put("Cloud", 25);
        wordsMap.put("Tag", 25);
        wordsMap.put("Count", 35);
        wordsMap.put("Test", 11);
        wordsMap.put("Log", 11);
        //15
        wordsMap.put("the", 10);
        wordsMap.put("story", 2);
        wordsMap.put("news", 6);
        wordsMap.put("drawing", 5);
        wordsMap.put("chart", 4);
        wordsMap.put("nice", 2);
        wordsMap.put("hi", 8);
        wordsMap.put("newspaper", 9);
        wordsMap.put("coffe", 2);
        wordsMap.put("logo", 20);
        wordsMap.put("cloudy", 10);
        wordsMap.put("rain", 5);
        wordsMap.put("troll", 8);
        wordsMap.put("step", 6);
        wordsMap.put("own", 3);
       //
        wordsMap.put("multiplies", 10);
        wordsMap.put("good", 2);
        wordsMap.put("area", 6);
        wordsMap.put("travel", 5);
        wordsMap.put("core", 4);
        wordsMap.put("store", 2);
        wordsMap.put("emulator", 8);
        wordsMap.put("laptop", 9);
        wordsMap.put("joke", 2);
        wordsMap.put("jungle", 20);
        wordsMap.put("kitty", 10);
        wordsMap.put("hello", 5);
        wordsMap.put("ajax", 8);
        wordsMap.put("tron", 6);
        wordsMap.put("me", 3);
        //
      /* wordsMap.put("sky", 10);
        wordsMap.put("logs", 2);
        wordsMap.put("warn", 6);
        wordsMap.put("funny", 5);
        wordsMap.put("lore", 4);
        wordsMap.put("sex", 2);
        wordsMap.put("fuck", 8);
        wordsMap.put("damit", 9);
        wordsMap.put("arshlog", 2);
        wordsMap.put("doodle", 20);
        wordsMap.put("rap", 10);
        wordsMap.put("smooth", 5);
        wordsMap.put("style", 8);
        wordsMap.put("css", 6);
        wordsMap.put("script", 3);
        //
        wordsMap.put("tank", 10);
        wordsMap.put("bird", 2);
        wordsMap.put("dog", 6);
        wordsMap.put("fruit", 5);
        wordsMap.put("ship", 4);
        wordsMap.put("bond", 2);
        wordsMap.put("007", 8);
        wordsMap.put("poker", 9);
        wordsMap.put("guns", 2);
        wordsMap.put("drugs", 20);
        wordsMap.put("dildo", 10);
        wordsMap.put("wiskey", 5);
        wordsMap.put("jin", 8);
        wordsMap.put("cocaine", 6);
        wordsMap.put("trap", 3);
        //
        wordsMap.put("toll", 10);
        wordsMap.put("link", 2);
        wordsMap.put("and", 6);
        wordsMap.put("or", 5);
        wordsMap.put("xor", 4);
        wordsMap.put("binary", 2);
        wordsMap.put("hex", 8);
        wordsMap.put("fridge", 9);
        wordsMap.put("cup", 2);
        wordsMap.put("shit", 20);
        wordsMap.put("lamb", 10);
        wordsMap.put("pork", 5);
        wordsMap.put("juice", 8);
        wordsMap.put("swing", 6);
        wordsMap.put("hibernate", 3);
        //
                wordsMap.put("pepper", 10);
        wordsMap.put("offspring", 2);
        wordsMap.put("brake", 6);
        wordsMap.put("speed", 5);
        wordsMap.put("success", 4);
        wordsMap.put("hackaton", 2);
        wordsMap.put("kinect", 8);
        wordsMap.put("audio", 9);
        wordsMap.put("video", 2);
        wordsMap.put("other", 20);
        wordsMap.put("select", 10);
        wordsMap.put("option", 5);
        wordsMap.put("tram", 8);
        wordsMap.put("nigger", 6);
        wordsMap.put("white", 3);
        //
                wordsMap.put("apple", 10);
        wordsMap.put("mac", 2);
        wordsMap.put("pc", 6);
        wordsMap.put("straight", 5);
        wordsMap.put("rails", 4);
        wordsMap.put("tnt", 2);
        wordsMap.put("bmw", 8);
        wordsMap.put("orks", 9);
        wordsMap.put("starkraft", 2);
        wordsMap.put("chair", 20);
        wordsMap.put("star", 10);
        wordsMap.put("junkey", 5);
        wordsMap.put("nikon", 8);
        wordsMap.put("allstar", 6);
        wordsMap.put("luxoft", 3);*/
        return wordsMap;
    }

}
